//
//  H_HoneyViewController.m
//  Honey
//
//  Created by 贾亚涵 on 16/3/17.
//  Copyright © 2016年 贾亚涵. All rights reserved.
//

#import "H_HoneyViewController.h"
#import "H_HoneyAnniversaryViewController.h"
#import "H_HoneyChatViewController.h"
#import "H_HoneyBackgroundViewController.h"

@interface H_HoneyViewController ()<UICollectionViewDelegate,UIImagePickerControllerDelegate>
{
    UIImageView * _honeyBackImageView;
    UIButton * _honeyLeftBtn;
    UIButton * _honeyCenterBtn;
    UIButton * _honeyRightBtn;
    
}

@end

#define Honey_LeftBtn_T 1000
#define Honey_CenterBtn_T 1200
#define Honey_RightBtn_T 1400

@implementation H_HoneyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //初始化honey界面
    [self initHoneyView];
    
    
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    
}

-(void)initHoneyView
{
    _honeyBackImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height)];
    _honeyBackImageView.image = [UIImage imageNamed:@"honey_back1"];
    //给UIImageView加手势，可点击
    _honeyBackImageView.userInteractionEnabled = YES;
    [self.view addSubview:_honeyBackImageView];
    
    _honeyLeftBtn = [self addUIButtonRect:CGRectMake(55, Screen_Height-140, 70, 70) Title:@"纪念日" Tag:Honey_LeftBtn_T];
    _honeyCenterBtn = [self addUIButtonRect:CGRectMake(CGRectGetMaxX(_honeyLeftBtn.frame)+27.5, Screen_Height-140, 70, 70) Title:@"聊天" Tag:Honey_CenterBtn_T];
    _honeyRightBtn = [self addUIButtonRect:CGRectMake(CGRectGetMaxX(_honeyCenterBtn.frame)+27.5, Screen_Height-140, 70, 70) Title:@"背景" Tag:Honey_RightBtn_T];
    
}


//有三个UIButton，可以进行方法的抽出
#pragma mark - UIButton
-(UIButton *)addUIButtonRect:(CGRect)rect Title:(NSString *)title Tag:(NSInteger)tag
{
    UIButton * _Btn = [[UIButton alloc] initWithFrame:rect];
    //UIButton上的字
    [_Btn setTitle:title forState:UIControlStateNormal];
    //UIButton的背景颜色
    _Btn.backgroundColor = [UIColor colorWithRed:246/255.0f green:157/255.0f blue:182/255.0f alpha:1];
    //UIButton的圆角
    _Btn.layer.cornerRadius = 25.0f;
    //UIButton的tag值
    _Btn.tag = tag;
    //UIButton的点击事件
    [_Btn addTarget:self action:@selector(HoneyBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [_honeyBackImageView addSubview:_Btn];
    
    
    return _Btn;
}

//三个Button的点击事件
-(void)HoneyBtnClicked:(id)sender
{
    if (sender && [sender isKindOfClass:[UIButton class]])
    {
        UIButton * _button = (UIButton *)sender;
        switch (_button.tag)
        {
            case Honey_LeftBtn_T:
            {
                H_HoneyAnniversaryViewController * anni = [H_HoneyAnniversaryViewController new];
                [self.navigationController pushViewController:anni animated:YES];
            }
                
                break;
            case Honey_CenterBtn_T:
            {
                H_HoneyChatViewController * chat = [H_HoneyChatViewController new];
                //把controller从下方推出
               [self.navigationController presentViewController:chat animated:YES completion:^{
                   
               }];
            }
                
                break;
            case Honey_RightBtn_T:
            {
                H_HoneyBackgroundViewController * back = [H_HoneyBackgroundViewController new];
                [self.navigationController pushViewController:back animated:YES];
            }
                
                break;
                
            default:
                break;
        }
    }
    
    
    
}

@end
